package com.xzzz.irda.guardcat.core.metric.memory;

import java.io.Serializable;

/**
 * 使用信息
 *
 * <pre>
 *        +----------------------------------------------+
 *        +////////////////           |                  +
 *        +////////////////           |                  +
 *        +----------------------------------------------+
 *
 *        |--------|
 *           init
 *        |---------------|
 *               used
 *        |---------------------------|
 *                  committed
 *        |----------------------------------------------|
 *                            max
 *
 *      max >= committed / used / init
 *      committed >= used
 *      committed 可以小于 init
 *
 *      </pre>
 *
 * @author xzzz
 * @since 1.0.0
 */
public class UsageInfo implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 初始值
     */
    private long initValue;

    /**
     * 最大值
     */
    private long maxValue;

    /**
     * 已提交值
     */
    private long committedValue;

    /**
     * 已用值
     */
    private long usedValue;


    public UsageInfo(long initValue, long maxValue, long committedValue, long usedValue) {
        this.initValue = initValue;
        this.maxValue = maxValue;
        this.committedValue = committedValue;
        this.usedValue = usedValue;
    }

    public long getInitValue() {
        return initValue;
    }

    public long getMaxValue() {
        return maxValue;
    }

    public long getCommittedValue() {
        return committedValue;
    }

    public long getUsedValue() {
        return usedValue;
    }

    @Override
    public String toString() {
        return "使用信息{" +
                "初始值=" + initValue + "(" + (initValue >> 10) + "K) " +
                ", 最大值=" + maxValue + "(" + (maxValue >> 10) + "K) " +
                ", 已提交值=" + committedValue + "(" + (committedValue >> 10) + "K) " +
                ", 已用值=" + usedValue + "(" + (usedValue >> 10) + "K) " +
                '}';
    }
}
